function insideJS() {
    alert('Test alert');
}

function Show1_onclick() {
    document.getElementById('Panel1').style.display ='block';
    document.getElementById('Panel2').style.display ='none';
}

function Show2_onclick() {
    document.getElementById('Panel1').style.display ='none';
    document.getElementById('Panel2').style.display ='block';
}

function initializeLoad() {
    var latlng = new google.maps.LatLng(-34.397, 150.644);
    var myOptions = {
        zoom: 8,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);
}

var map;

function initialize() {
    var myOptions = {
        zoom: 15,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById('map_canvas'),
            myOptions);

    // Try HTML5 geolocation
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(function (position) {
            var pos = new google.maps.LatLng(position.coords.latitude,
                                             position.coords.longitude);

            var infowindow = new google.maps.InfoWindow({
                map: map,
                position: pos,
                content: 'Location found using HTML5.'
            });

            map.setCenter(pos);
        }, function () {
            handleNoGeolocation(true);
        });
    } else {
        // Browser doesn't support Geolocation
        handleNoGeolocation(false);
    }

    //event
    google.maps.event.addListener(map, 'click', function (event) {
        placeMarker(event.latLng);
    });
}

function handleNoGeolocation(errorFlag) {
    if (errorFlag) {
        var content = 'Error: The Geolocation service failed.';
    } else {
        var content = 'Error: Your browser doesn\'t support geolocation.';
    }

    var options = {
        map: map,
        position: new google.maps.LatLng(60, 105),
        content: content
    };

    var infowindow = new google.maps.InfoWindow(options);
    map.setCenter(options.position);
}

google.maps.event.addDomListener(window, 'load', initialize);

// ============================simpleMarker================================== //
function simpleMarker() {
    var myLatlng = new google.maps.LatLng(-25.363882, 131.044922);
    var myOptions = {
        zoom: 4,
        center: myLatlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    var marker = new google.maps.Marker({
        position: myLatlng,
        map: map,
        title: "Hello World!"
    });
}

// ============================event================================== //

function placeMarker(location) {
    var marker = new google.maps.Marker({
        position: location,
        map: map
    });

    //map.setCenter(location);

    var myOptions = {
        zoom: map.getZoom(),
        center: location, //myLatlng here
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    //map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    var marker = new google.maps.Marker({
        position: location,
        map: map,
        title: "Đây là địa chỉ yêu thích của tôi Update"
    });
    markers.push(marker);
    var content = '<div style="text-align: center; font-size:14px;"><center><b>Làng sinh viên Hacinco</b></center><img width="240" height="180" src="Styles/Images/75162321-129353_Hacinco2.jpg"/><div style="margin: auto; text-align: right; width: 240px;" class="linkbutton"><a href="http://www.panoramio.com/user/279908">Edson Walter Cavalari</a></div><div class="linkbutton"><a href="http://www.panoramio.com/photo/7253919" target="_blank">See more photos at Panoramio.com</a></div><br/><div class="linkbutton"><a href="http://www.google.com/search?q=site:wikipedia.org+Diamantino,Brazil&amp;btnI=I\'m+Feeling+Lucky" target="_blank">Read more about this location</a></div><div class="linkbutton"><a href="javascript:void(0)" id="zoomLink">Zoom in to this location</a></div></div>';
    google.maps.event.addListener(marker, 'click', function (e) {
        var infobox = new SmartInfoWindow({ position: marker.getPosition(), map: map, content: content });
    });
}

// ============================= Property view =================================

var cloud;
var counter = 0;
var markers = [];

function init() {
    var options = {
        zoom: 2,
        center: new google.maps.LatLng(0, 0),
        mapTypeId: google.maps.MapTypeId.SATELLITE
    }
    map = new google.maps.Map(document.getElementById('map_canvas'), options);
    for (var i = 0; i < 15; i++) {
        makeMarker(locations[i]);
    }
    centerMap();
}

function centerMap() {
    map.setCenter(markers[markers.length - 1].getPosition());
}


function makeMarker(location) {
//    var markerOptions = { map: map, position: new google.maps.LatLng(location.lat, location.lng) };
//    var marker = new google.maps.Marker(markerOptions);
//    markers.push(marker);
//    var content = '<div style="text-align: center; font-size:14px;"><center><b>Diamantino, Brazil</b></center>
//    <img width="240" height="180" src="http://mw2.google.com/mw-panoramio/photos/small/7253919.jpg"/>
//    <div style="margin: auto; text-align: right; width: 240px;" class="linkbutton">
//    <a href="http://www.panoramio.com/user/279908">Edson Walter Cavalari</a></div><div class="linkbutton">
//    <a href="http://www.panoramio.com/photo/7253919" target="_blank">See more photos at Panoramio.com</a></div><br/><div class="linkbutton">
//    <a href="http://www.google.com/search?q=site:wikipedia.org+Diamantino,Brazil&amp;btnI=I\'m+Feeling+Lucky" target="_blank">Read more about this location</a>
//    </div><div class="linkbutton"><a href="javascript:void(0)" id="zoomLink">Zoom in to this location</a></div></div>';

//    google.maps.event.addListener(marker, 'click', function (e) {
//        var infobox = new SmartInfoWindow({ position: marker.getPosition(), map: map, content: content });
//    });
}